/*! lzf */

function deletePic(t) {
    dialog({
        title: "删除图片",
        width: 400,
        height: 60,
        content: "图片删除了不能恢复，你确定要删除么？",
        button: [{
            value: "确定", callback: function (a) {
                var e = {
                    src: $(t).parent().parent().find("img").attr("src"),
                    files_id: $(t).parent().parent().attr("file-id")
                };
                $(t).parent().parent().remove()
                $("#pic_apart_holder div:first .biaoji").css("display","");
            }, autofocus: !0
        }, {value: "取消"}]
    }).show()
}

function setPoster(a) {
    $("#pic_apart_holder .show_trangle").replaceWith('<div class="pic-regular"><span class="icon icon-trash" onclick="deletePic(this);"></span><span class="icon-feng" onclick="setPoster(this);">封</span></div>'), $(a).parent().replaceWith('<div class="show_trangle" data-status="0"><span class="icon icon-trash" onclick="deletePic(this);"></span><div class="pic_trangle"></div><span id="feng">封</span></div>')
}

function getPropertyByName(a, e) {
    var t = {ppt_name: a};
    $.post(base.site_url() + "client/search/search/getPropertyByName", {data: JSON.stringify(t)}, function (a) {
        var e, t = "", n = a.data;
        for (var s in n) t += '<p onclick="setPropertyName(this);" class="searchItem" data-id="' + (e = n[s]).property_id + '"><span class="ppt-name">' + e.ppt_name + '</span><span class="prop-region"><span>' + e.ct_name + "-" + e.region_name + "</span></p>";
        $("#searchCon").html(t)
    }, "json")
}

function setPropertyName(a) {
    var e = $(a).attr("data-id"), t = $(a).find(".ppt-name").text();
    $("#property_name").attr("data-id", e), $("#property_name").val(t)
}

$(document).ready(function () {
    $("#temporary_apart").click(function () {
        "加载中..." != $(this).text() && ($(this).text("加载中..."), aptNewHandler.saveApartment(1))
    }), $("#pic_callback").click(function () {
        $("#add_apart_pic").addClass("none"), $("#add_apart_msg").removeClass("none")
    }), base.is_ie() && base.fuck_ie_version(10) && base.flash_version() < 11 && window.confirm("您的flash版本过低，下载最新flash") && (window.location.href = "http://w.x.baidu.com/alading/anquan_soft_down_ub/17153"), $("#show_entrust").click(function () {
        $(".col-tab-active").removeClass("col-tab-active"), $(this).addClass("col-tab-active"), $("#entrust_msg").removeClass("none"), $("#add_apart_msg").addClass("none"), $("#add_apart_pic").addClass("none")
    }), $("#show_person").click(function () {
        $(".col-tab-active").removeClass("col-tab-active"), $(this).addClass("col-tab-active"), $("#entrust_msg").addClass("none"), $("#add_apart_msg").removeClass("none")
    }), $("#entrust_btn").click(function () {
        var a = {
            ea_type: $("#ea_type").val(),
            ea_owner_name: $("#ea_owner_name").val(),
            ea_neighborhood_name: $("#ea_neighborhood_name").val(),
            ea_rooms: $("#ea_rooms").val(),
            ea_rent: $("#ea_rent").val()
        };
        $.post(base.site_url() + "client/memMng/memApartmentMng/saveEntrustApartInfo", {data: JSON.stringify(a)}, function (a) {
            0 == a.code ? (base.alertMsg({text: "委托成功"}), location.href = base.site_url() + "user/entrust") : base.alertMsg({text: a.message})
        }, "json")
    })
});